
using Youz.Common.Helper;
using Youz.Common.DAL;
using Youz.Common.Entity;
using System;
using System.Data;
using System.Data.SqlClient;

namespace Youz.Common.BLL
{
    /// <summary>
    /// Right_Roleinfo BLL Class
    /// </summary>
    public partial class Right_RoleinfoBLL : BaseBLL
    {
        Right_RoleinfoDAL dal;

        public Right_RoleinfoBLL()
        {
            dal = new Right_RoleinfoDAL();
            base.ModuleName = "Right_Roleinfo";
            base.MenuName = "Right_Roleinfo";
        }

        #region  成员方法
        /// <summary>
        ///  新增一条数据
        /// </summary>
        public bool Add(Right_Roleinfo model)
        {
            var r = dal.Add(model);
            base.WriteOperationLog(OperationType.Add, r, model.RoleID);
            return r;
        }

        /// <summary>
        ///  保存一条数据
        /// </summary>
        public bool Update(Right_Roleinfo model)
        {
            var r = dal.Update(model);
            base.WriteOperationLog(OperationType.Update, r, model.RoleID);
            return r;
        }

        /// <summary>
        /// 删除一条数据
        ///</summary>
        public bool Delete(Guid RoleID)
        {
            var r = dal.Delete(RoleID);
            base.WriteOperationLog(OperationType.Delete, r, RoleID);
            return r;
        }

        public bool Exists(SiteType type, string roleName)
        {
            return dal.Exists(type, roleName);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Right_Roleinfo Get(Guid RoleID)
        {
            return dal.Get(RoleID);
        }

        /// <summary>
        /// 得到一个JSON对象
        /// </summary>
        public string GetJson(Guid RoleID)
        {
            return Utility.GetJsonByObject(Get(RoleID));
        }

        /// <summary>
        /// 获得站点默认角色
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public Guid GetDefault()
        {
            return dal.GetDefault(Utility.CurrentSiteType);
        }

        /// <summary>
        /// 获得数据列表分页
        /// </summary>
        public DataTable Gets(string sqlWhere, SiteType siteType, int pageindex, int pagesize, out int total, params SqlParameter[] cmdParms)
        {
            return dal.Gets(sqlWhere, siteType, pageindex, pagesize, out total, cmdParms);
        }

        /// <summary>
        ///获得默认角色
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public bool GetDefault(Guid RoleID, int IsDefault, SiteType siteType)
        {
            return dal.GetDefault(RoleID, IsDefault, siteType);
        }
        #endregion  成员方法
    }
}


